package com.example.common.entity;

import jakarta.persistence.*;
import lombok.Data;

import java.math.BigInteger;


@Entity
@Table(name = "sys_roles_menus")
@Data
public class SysRolesMenus {
    
    @EmbeddedId
    private SysRolesMenusId id;
    
    @ManyToOne
    @MapsId("roleId")
    @JoinColumn(name = "role_id", referencedColumnName = "role_id")
    private SysRole sysRole;
    
    @ManyToOne
    @MapsId("menuId")
    @JoinColumn(name = "menu_id", referencedColumnName = "menu_id")
    private SysMenu sysMenu;
    
    @Transient
    public BigInteger getRoleId() {
        return sysRole.getRoleId();
    }
    
    public void setRoleId(BigInteger roleId) {
        SysRole role = new SysRole();
        role.setRoleId(roleId);
        this.sysRole = role;
    }
    
    @Transient
    public BigInteger getMenuId() {
        return sysMenu.getMenuId();
    }
    
    public void setMenuId(BigInteger menuId) {
        SysMenu menu = new SysMenu();
        menu.setMenuId(menuId);
        this.sysMenu = menu;
    }
}
